
/**
 * @brief
 * @link https://nexus.hexagon.com/documentationcenter/en-US/bundle/MSC_Nastran_2024.2/page/Nastran_Combined_Book/qrg/bulkc1/TOC.CFAST.xhtml
 * @version  0.1
 * @author   wuxingchuang
 * @date     2025.04.07
 *          _
 *      ___| |__   ___ _ __   __ _  ___  _ __   __ _
 *     / __| '_ \ / _ \ '_ \ / _` |/ _ \| '_ \ / _` |
 *     \__ \ | | |  __/ | | | (_| | (_) | | | | (_| |
 *     |___/_| |_|\___|_| |_|\__, |\___/|_| |_|\__, |
 *                           |___/             |___/
 * @copyright (c) 2024 by 神工仿真, All Rights Reserved.
 */
#pragma once
#include "DataStructure/Common/Id.h"
#include "DataStructure/Common/Real.h"
#include "DataStructure/Input/Element/ElementBase.h"
#include <cstring> 

SG_DATASTRUCTURE_FEM_NAMESPACE_OPEN

struct CFASTData : public ElementBase
{
    /**
     * @brief    CFAST 单元类型
     * 
     * @author   wanghuan
     * @date     2025.04.09
     */
    enum CFASTTypes
    {
        CFASTType_Unknow = -1,
        CFASTType_Elem   =  0,
        CFASTType_Prop   =  1  
    };
    
    CFASTTypes GetType () const;


    SG::DataStructure::Common::Id m_pId = 0;   // Property identification number of a PFAST entry. (Integer > 0; Default = EID)
    SG::DataStructure::Common::Id m_cId = -1;  //
    /**
       Specifies the surface patch definition: (Character)
       If TYPE = ‘PROP’, the surface patch connectivity between patch A and patch B is defined with two PSHELL (or PCOMP) properties with
       property ids given by IDA and IDB.
       If TYPE = ‘ELEM’, the surface patch connectivity between patch A and patch B is defined with two
       shell element ids given by IDA and IDB.
        */
    char m_type[4] = { 0 };
    // Property id (for PROP option) or Element id (for ELEM option) defining patches A and B. IDA ≠ IDB (Integer > 0)
    SG::DataStructure::Common::I64 m_ida = 0;
    // Property id (for PROP option) or Element id (for ELEM option) defining patches A and B. IDA ≠ IDB (Integer > 0)
    SG::DataStructure::Common::I64 m_idb      = 0;
    SG::DataStructure::Common::I64 m_gs       = 0;      // Grid point defining the location of the fastener
    SG::DataStructure::Common::I64 m_g[2]     = { 0 };  // Grid ids of piercing points on patches A and B.
    SG::DataStructure::Common::I64 m_gh[8]    = { 0 };  //
    SG::DataStructure::Common::Real m_xs       = 0;      // Location of the fastener in basic. Required if neither GS nor GA is defined.
    SG::DataStructure::Common::Real m_ys       = 0;      // Location of the fastener in basic. Required if neither GS nor GA is defined.
    SG::DataStructure::Common::Real m_zs       = 0;      // Location of the fastener in basic. Required if neither GS nor GA is defined.
    SG::DataStructure::Common::Id  m_domainId = 0;      //
};

inline CFASTData::CFASTTypes CFASTData::GetType () const
{
    if (memcmp (m_type, "ELEM", 4) == 0)
    {
        return CFASTTypes::CFASTType_Elem;
    }

    
    if (memcmp (m_type, "PROP", 4) == 0)
    {
        return CFASTTypes::CFASTType_Prop;
    }
    
    return CFASTTypes::CFASTType_Unknow;
}

///< @brief 判断数据是否相等
DECLSPEC bool operator== (const CFASTData& val1, const CFASTData& val2);

SG_DATASTRUCTURE_FEM_NAMESPACE_CLOSE
